<template>
  <div class="handleOrder">
    <!-- ========修改弹窗======-->
    <!--、、销售操作订单：初审客户-->
    <div>
      <el-dialog
        title="初审客户"
        width="45%"
        class="fns-el-dialog"
        :close-on-click-modal="false"
        :visible.sync="+updateMsg.code === 1"
        :before-close="handleClose">
        <!--// 公司客户-->
        <div :span="24"  v-if="+updateMsg.customerType === 1">
          <el-form ref="updateBox" :model="form1.goodsOrderCustomerInfoResultDtos[0]" :rules="rules" label-width="130px" style="margin-left:6px;">

            <el-row>
              <el-col :span="11">
                <el-form-item label="客户类型：">
                  <el-input v-model="form1.customerType" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="订单编号：">
                  <el-input v-model="form1.orderCode " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="经手销售：">
                  <el-input v-model="form1.saleName" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="经纪人：" >
                  <el-input v-model="form1.brokerName " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23">
                <el-form-item label="公司名称：" prop="customerName">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].customerName"  :maxlength="length.max50" placeholder="请输入公司名称" clearable></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="上牌地区：" prop="licensedArea">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].licensedArea" :maxlength="length.max20" placeholder="请输入上牌地区" clearable></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="开户行：" prop="bankOfDeposit">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].bankOfDeposit" :maxlength="length.max20" placeholder="请输入开户行" clearable></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11" class="itemNum">
                <el-form-item label="税号/统一社会信用代码：" prop="creditCode">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].creditCode" placeholder="请输入税号" :maxlength="length.max18" clearable></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="账号：" prop="account">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].account" placeholder="请输入账号" :maxlength="length.max20" clearable></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="公司电话：" prop="customerPhone">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].customerPhone" :maxlength="length.max14" placeholder="请输入公司电话" clearable></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23">
                <el-form-item label="公司地址：" prop="customerAddress">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].customerAddress" :maxlength="length.max100" placeholder="请输入公司地址" clearable></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" style="margin-top: -10px">
                <el-form-item label="营业执照：">
                  <div>
                    <a :href=" imgUrl + form1.goodsOrderCustomerInfoResultDtos[0].businessLicenceUrl " target="_blank">{{ form1.goodsOrderCustomerInfoResultDtos[0].businessLicenceUrl || '' }}</a>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" style="margin-top: -30px">
                <el-form-item label="公司开票：">
                  <div>
                    <a href=" imgUrl + form1.goodsOrderCustomerInfoResultDtos[0].billingInformationUrl " target="_blank">{{ form1.goodsOrderCustomerInfoResultDtos[0].billingInformationUrl || '' }}</a>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" class="itemConfirm" style="margin-top: -30px">
                <el-form-item label="销售确认情况：" prop="confirmType">
                  <el-radio-group v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmType">
                    <el-radio :label="1">确认</el-radio>
                    <el-radio :label="0">驳回</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row  v-if="+form1.goodsOrderCustomerInfoResultDtos[0].confirmType === 0">
              <el-col :span="23">
                <el-form-item label="驳回原因：" prop="confirmDetails">
                  <el-input type="textarea" v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmDetails" :maxlength="length.max100" placeholder="请填写原因"></el-input>
                </el-form-item>
              </el-col>
            </el-row>

          </el-form>
        </div>

        <!--// 个人客户-->
        <div :span="24"  v-else >
          <el-form ref="updateBox" :model="form1.goodsOrderCustomerInfoResultDtos[0]" :rules="rules" label-width="110px" style="margin-left:6px;">

            <el-row>
              <el-col :span="11">
                <el-form-item label="客户类型：">
                  <el-input v-model="form1.customerType" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="订单编号：">
                  <el-input v-model="form1.orderCode " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="经手销售：">
                  <el-input v-model="form1.saleName" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="经纪人：" >
                  <el-input v-model="form1.brokerName " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <!--// 客户管理-->
            <el-row class="fns-tabs">
              <el-col :span="24">
                <el-tabs v-model="activeName">
                  <el-tab-pane :label="'客户'+ (index + 1)" :name="String(index)" v-for="(item, index) in form1.goodsOrderCustomerInfoResultDtos" :key="index">
                      <el-row>
                        <el-col :span="11">
                          <el-form-item label="个人姓名：" prop="customerName">
                            <el-input v-model="item.customerName" placeholder="请输入个人姓名" :maxlength="length.max10" clearable></el-input>
                          </el-form-item>
                        </el-col>

                        <el-col :span="11" :offset="1">
                          <el-form-item label="上牌地区：" prop="licensedArea">
                            <el-input v-model="item.licensedArea" placeholder="请输入上牌地区" :maxlength="length.max10" clearable></el-input>
                          </el-form-item>
                        </el-col>
                      </el-row>

                      <el-row>
                        <el-col :span="11">
                          <el-form-item label="身份证号："  prop="customerIdCard">
                            <el-input v-model="item.customerIdCard" placeholder="请输入身份证号" :maxlength="length.max18" required clearable></el-input>
                          </el-form-item>
                        </el-col>

                        <el-col :span="11" :offset="1">
                          <el-form-item label="个人电话：" prop="customerPhone">
                            <el-input v-model="item.customerPhone" placeholder="请输入个人电话" :maxlength="length.max14" clearable></el-input>
                          </el-form-item>
                        </el-col>
                      </el-row>

                      <el-row class="fns-form-item">
                        <el-col :span="11">
                          <el-form-item label="身份证正面：">
                            <a href="item.customerBackUrl">{{ item.customerBackUrl || '' }}</a>
                          </el-form-item>
                        </el-col>

                        <el-col :span="11" :offset="1">
                          <el-form-item label="身份证反面：">
                            <a href="imgUrl + item.customerFrontUrl" target="_blank">{{ item.customerFrontUrl || ''}}</a>
                          </el-form-item>
                        </el-col>
                      </el-row>

                      <el-row class="fns-form-item">
                        <el-col :span="11">
                          <el-form-item label="营业执照：">
                            <div><a href=" imgUrl + item.businessLicenceUrl " target="_blank">{{ item.businessLicenceUrl || '' }}</a></div>
                          </el-form-item>
                        </el-col>

                        <el-col :span="11" :offset="1">
                          <el-form-item label="公司开票：">
                            <div>
                              <a href=" imgUrl + item.billingInformationUrl " target="_blank">{{ item.billingInformationUrl || '' }}</a>
                            </div>
                          </el-form-item>
                        </el-col>
                      </el-row>

                      <el-row class="fns-form-item">
                        <el-col :span="23" >
                          <el-form-item label="附加照片：" class="itemZp">
                            <div><a href=" imgUrl + item.annexI " target="_blank">{{ item.annexI || ''}}</a></div>
                            <div><a href=" imgUrl + item.annexII " target="_blank">{{ item.annexII || ''}}</a></div>
                            <div><a href=" imgUrl + item.annexIII " target="_blank">{{ item.annexIII || ''}}</a></div>
                          </el-form-item>
                        </el-col>
                      </el-row>

                  </el-tab-pane>
                </el-tabs>
              </el-col>
            </el-row>


            <el-row>
              <el-col :span="23" class="itemConfirm" style="margin-top: 10px;">
                <el-form-item label="销售确认情况：" prop="confirmType">
                  <el-radio-group v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmType">
                    <el-radio :label="1">确认</el-radio>
                    <el-radio :label="0">驳回</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row v-if="+form1.goodsOrderCustomerInfoResultDtos[0].confirmType === 0">
              <el-col :span="23">
                <el-form-item label="驳回原因：" prop="confirmDetails">
                  <el-input type="textarea" :maxlength="length.max100" v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmDetails" placeholder="请填写原因"></el-input>
                </el-form-item>
              </el-col>
            </el-row>

          </el-form>
        </div>

        <!--// 底部-->
        <span slot="footer" class="dialog-footer">
          <el-button @click="updateMsg.code = -1">取 消</el-button>
          <el-button type="primary" @click="submitForm">提 交</el-button>
        </span>
      </el-dialog>
    </div>
    <!--、、销售操作订单：终审客户-->
    <div>
      <el-dialog
        title="终审客户"
        width="45%"
        class="fns-el-dialog"
        :close-on-click-modal="false"
        :visible.sync="+updateMsg.code === 2"
        :before-close="handleClose">
        <!--// 公司客户-->
        <div :span="24" v-if="+updateMsg.customerType === 1">
          <el-form ref="updateBox" :model="form1.goodsOrderCustomerInfoResultDtos[0]" :rules="rules" label-width="130px" style="margin-left:6px;">

            <el-row>
              <el-col :span="11">
                <el-form-item label="客户类型：">
                  <el-input v-model="form1.customerType" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="订单编号：">
                  <el-input v-model="form1.orderCode " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="经手销售：">
                  <el-input v-model="form1.saleName" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="经纪人：" >
                  <el-input v-model="form1.brokerName " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23">
                <el-form-item label="公司名称：" >
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].customerName"  :maxlength="length.max50" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="上牌地区：" >
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].licensedArea" :maxlength="length.max20" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="开户行：">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].bankOfDeposit" :maxlength="length.max20" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11" class="itemNum">
                <el-form-item label="税号/统一社会信用代码：">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].creditCode" placeholder="" :maxlength="length.max18" disabled></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="账号：" >
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].account" placeholder="" :maxlength="length.max20" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="公司电话：" >
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].customerPhone" :maxlength="length.max14" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23">
                <el-form-item label="公司地址：">
                  <el-input v-model="form1.goodsOrderCustomerInfoResultDtos[0].customerAddress" :maxlength="length.max100" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row >
              <el-col :span="11" style="margin-top: -20px">
                <el-form-item label="营业执照：" >
                  <div>
                    <a href=" imgUrl + form1.goodsOrderCustomerInfoResultDtos[0].businessLicenceUrl " target="_blank">{{ form1.goodsOrderCustomerInfoResultDtos[0].businessLicenceUrl || '' }}</a>
                  </div>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1" style="margin-top: -20px">
                <el-form-item label="公司开票：">
                  <div>
                    <a href="imgUrl + form1.goodsOrderCustomerInfoResultDtos[0].billingInformationUrl" target="_blank">{{ form1.goodsOrderCustomerInfoResultDtos[0].billingInformationUrl || ''}}</a>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" class="itemConfirm" style="margin-top: -30px">
                <el-form-item label="销售确认情况：" prop="saleUserId">
                 <div>确认</div>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" class='itemUser'>
                <div>
                  <span class="span1">确认人：</span>
                  <span>{{ form1.operator }}</span>
                </div>
                <div>
                  <span class="span1">确认时间：</span>
                  <span> {{ form1.operatingTime }} </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" class="itemConfirm">
                <el-form-item label="销售确认情况：" prop="confirmType">
                  <el-radio-group v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmType">
                    <el-radio :label="1">确认</el-radio>
                    <el-radio :label="0">驳回</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row  v-if="+form1.goodsOrderCustomerInfoResultDtos[0].confirmType === 0">
              <el-col :span="23">
                <el-form-item label="驳回原因：" prop="confirmDetails">
                  <el-input type="textarea" v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmDetails" :maxlength="length.max100" placeholder="请填写原因"></el-input>
                </el-form-item>
              </el-col>
            </el-row>


          </el-form>
        </div>

        <!--// 个人客户-->
        <div :span="24"  v-else >
          <el-form ref="updateBox" :model="form1.goodsOrderCustomerInfoResultDtos[0]" :rules="rules" label-width="110px" style="margin-left:6px;">

            <el-row>
              <el-col :span="11">
                <el-form-item label="客户类型：">
                  <el-input v-model="form1.customerType" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="订单编号：">
                  <el-input v-model="form1.orderCode " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="11">
                <el-form-item label="经手销售：">
                  <el-input v-model="form1.saleName" placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="11" :offset="1">
                <el-form-item label="经纪人：" >
                  <el-input v-model="form1.brokerName " placeholder="" disabled ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <!--// 客户管理-->
            <el-row class="fns-tabs">
              <el-col :span="24">
                <el-tabs v-model="activeName">
                  <el-tab-pane :label="'客户'+ (index + 1)" :name="String(index)" v-for="(item, index) in form1.goodsOrderCustomerInfoResultDtos" :key="index">
                    <el-row>
                      <el-col :span="11">
                        <el-form-item label="个人姓名：" >
                          <el-input v-model="item.customerName" placeholder="" :maxlength="length.max10" disabled></el-input>
                        </el-form-item>
                      </el-col>

                      <el-col :span="11" :offset="1">
                        <el-form-item label="上牌地区：" >
                          <el-input v-model="item.licensedArea" placeholder="" :maxlength="length.max10" disabled></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>

                    <el-row>
                      <el-col :span="11">
                        <el-form-item label="身份证号：" >
                          <el-input v-model="item.customerIdCard" placeholder="" :maxlength="length.max18"  disabled></el-input>
                        </el-form-item>
                      </el-col>

                      <el-col :span="11" :offset="1">
                        <el-form-item label="个人电话：">
                          <el-input v-model="item.customerPhone" placeholder="" :maxlength="length.max14" disabled></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>

                    <el-row class="fns-form-item">
                      <el-col :span="11">
                        <el-form-item label="身份证正面：">
                          <a href="item.customerBackUrl">{{ item.customerBackUrl || '' }}</a>
                        </el-form-item>
                      </el-col>

                      <el-col :span="11" :offset="1">
                        <el-form-item label="身份证反面：">
                          <a href="item.customerFrontUrl" target="_blank">{{ item.customerFrontUrl || ''}}</a>
                        </el-form-item>
                      </el-col>
                    </el-row>

                    <el-row class="fns-form-item">
                      <el-col :span="11">
                        <el-form-item label="营业执照：">
                          <div><a href=" imgUrl + item.businessLicenceUrl " target="_blank">{{ item.businessLicenceUrl || '' }}</a></div>
                        </el-form-item>
                      </el-col>

                      <el-col :span="11" :offset="1">
                        <el-form-item label="公司开票：">
                          <div>
                            <a href=" imgUrl + item.billingInformationUrl " target="_blank">{{ item.billingInformationUrl || '' }}</a>
                          </div>
                        </el-form-item>
                      </el-col>
                    </el-row>

                    <el-row class="fns-form-item">
                      <el-col :span="23" >
                        <el-form-item label="附加照片：" class="itemZp">
                          <div><a href=" imgUrl + item.annexI " target="_blank">{{ item.annexI || ''}}</a></div>
                          <div><a href=" imgUrl + item.annexII " target="_blank">{{ item.annexII || ''}}</a></div>
                          <div><a href=" imgUrl + item.annexIII " target="_blank">{{ item.annexIII || ''}}</a></div>
                        </el-form-item>
                      </el-col>
                    </el-row>

                  </el-tab-pane>
                </el-tabs>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" class="itemConfirm">
                <el-form-item label="销售确认情况：" prop="saleUserId">
                  <div>确认</div>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" class='itemUser'>
                <div>
                  <span class="span1">确认人：</span>
                  <span>{{ form1.operator }}</span>
                </div>
                <div>
                  <span class="span1">确认时间：</span>
                  <span> {{ form1.operatingTime }} </span>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="23" class="itemConfirm" style="margin-top: 10px;">
                <el-form-item label="销售确认情况：" prop="confirmType">
                  <el-radio-group v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmType">
                    <el-radio :label="1">确认</el-radio>
                    <el-radio :label="0">驳回</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row v-if="+form1.goodsOrderCustomerInfoResultDtos[0].confirmType === 0">
              <el-col :span="23">
                <el-form-item label="驳回原因：" prop="confirmDetails">
                  <el-input type="textarea" :maxlength="length.max100" v-model="form1.goodsOrderCustomerInfoResultDtos[0].confirmDetails" placeholder="请填写原因"></el-input>
                </el-form-item>
              </el-col>
            </el-row>

          </el-form>
        </div>

        <!--// 底部-->
        <span slot="footer" class="dialog-footer">
          <el-button @click="updateMsg.code = -1">取 消</el-button>
          <el-button type="primary" @click="submitForm">提 交</el-button>
        </span>
      </el-dialog>

    </div>
  </div>
</template>

<script>
  import { Message } from 'element-ui'
  import * as api from '@/api/order'
  import { mapState } from 'vuex'

  export default {
    props: {
      updateMsg: {
        type: Object
      }
    },
    data() {
      return {
        length: {
          max10: 10,
          max14: 14,
          max18: 18,
          max20: 20,
          max50: 50,
          max60: 60,
          max100: 100
        },
        areaLength: 50,
        disabled: '',
        modelTitle: '修改',
        dialogVisible: true,
        activeName: '0',
        formData1: {
          orderId: '',
          confirmDetails: '',
          confirmType: '',
          goodsOrderCustomerInfoUpdateDtos: []
        },
        form1: {
          customerType: '',
          orderCode: '',
          saleName: '',
          brokerName: '',
          id: '',
          itemConfirm: '',
          confirmTime: '',
          scaleName: '',
          confirmType: undefined,
          goodsOrderCustomerInfoResultDtos: [
            {
              licensedArea: '',
              companyAddress: '',
              bankOfDeposit: '',
              creditCode: '',
              account: '',
              customerPhone: '',
              customerName: '',
              confirmType: undefined
            }
          ]
        },
        rules: {
          customerName: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          licensedArea: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          orderCode: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          bankOfDeposit: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          creditCode: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          account: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          customerPhone: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          customerIdCard: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          confirmDetails: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ],
          confirmType: [
            { required: true, message: '必填项，不能为空', trigger: 'change' }
          ],
          customerAddress: [
            { required: true, message: '必填项，不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    watch: {
      dialogVisible() {
        if (this.$refs.formModel) {
          this.$refs.formModel.clearValidate()
        }
      }
    },
    components: {
    },
    created() {
      this.getMsgList()
    },
    computed: {
      ...mapState({
        imgUrl: state => state.userInfo.url
      })
    },
    methods: {
      getMsgList() {
        var orderId = { orderId: +this.updateMsg.id }
        api.customerModify(orderId).then((res) => {
          if (+res.code === 0) {
            // if (res.data.goodsOrderCustomerInfoResultDtos.length !== 0) {
            //   this.form1 = res.data
            // }
            this.form1 = res.data
            console.log(this.form1)
          }
        })
      },
      // 打开修改 and 增加 弹窗
      openBox(val, row) {
      },
      // 提交
      submitForm() {
        // if (+this.updateMsg.customerType === 2 && +this.updateMsg.code === 1) {
        //   var flag = false
        //   this.form1.goodsOrderCustomerInfoResultDtos.forEach(function(item, index) {
        //     if (item.customerName === '' || item.licensedArea === '' || item.customerIdCard === '' || item.customerPhone === '') {
        //       Message({
        //         message: '有必填项，不能为空',
        //         type: 'warning',
        //         duration: 2000
        //       })
        //       flag = true
        //     }
        //   })
        //   if (flag) {
        //     return
        //   }
        // }
        this.formData1.orderId = +this.updateMsg.id
        this.formData1.confirmDetails = this.form1.goodsOrderCustomerInfoResultDtos[0].confirmDetails
        this.formData1.confirmType = this.form1.goodsOrderCustomerInfoResultDtos[0].confirmType
        this.formData1.goodsOrderCustomerInfoUpdateDtos = this.form1.goodsOrderCustomerInfoResultDtos
        var arr = []
        if (+this.updateMsg.code === 1 && +this.updateMsg.customerType === 2) {
          for (var [index, item] of new Map(this.formData1.goodsOrderCustomerInfoUpdateDtos.map((item, i) => [i, item]))) {
            if (item.customerName === '' || item.customerPhone === '' || item.customerIdCard === '' || item.licensedArea === '') {
              Message({
                message: '客户' + (index + 1) + '有必填项，不能为空',
                type: 'warning',
                duration: 2000
              })
              this.activeName = index + ''
              return
            }
          }
        }
        this.formData1.goodsOrderCustomerInfoUpdateDtos.forEach(function(item, index) {
          var obj = {
            account: item.account || '',
            bankOfDeposit: item.bankOfDeposit || '',
            creditCode: item.creditCode || '',
            customerAddress: item.customerAddress || '',
            customerIdCard: item.customerIdCard || '',
            customerName: item.customerName || '',
            customerPhone: item.customerPhone || '',
            id: item.id || '',
            licensedArea: item.licensedArea || ''
          }
          arr.push(obj)
        })
        this.formData1.goodsOrderCustomerInfoUpdateDtos = arr
        this.$refs['updateBox'].validate((valid) => {
          if (valid) {
            if (+this.updateMsg.code === 1) {
              api.customerSave(this.formData1).then((res) => {
                if (+res.code === 0) {
                  this.$emit('queryList')
                  this.updateMsg.code = false
                }
              }).catch(err => {
                if (+err.code === 1020) {
                  Message({
                    message: '该订单状态已改变，请关闭对话框并刷新订单列表',
                    type: 'warning',
                    duration: 2000
                  })
                }
              })
            } else if (+this.updateMsg.code === 2) {
              this.formData1.goodsOrderCustomerInfoUpdateDtos = []
              api.customerSave(this.formData1).then((res) => {
                if (+res.code === 0) {
                  this.$emit('queryList')
                  this.updateMsg.code = false
                }
              }).catch(err => {
                if (+err.code === 1020) {
                  Message({
                    message: '该订单状态已改变，请关闭对话框并刷新订单列表',
                    type: 'warning',
                    duration: 2000
                  })
                }
              })
            }
          }
        })
      },
      handleClose(done) {
        this.updateMsg.code = -1
      }
    }
  }
</script>
<style lang="scss">
  .itemNum {
    .el-form-item__label {
      line-height: 18px;
    }
  }
  .handleOrder {
    position: relative;
    padding: 20px;
    .el-dialog {
      .el-form-item__label {
       width: 120px!important;
      }
      .el-form-item__content {
        margin-left: 120px!important;
      }
      .itemUser {
        margin-top: -25px;
        display: inline-block;
        .span1 {
          display: inline-block;
          width: 110px;
          text-align: right;
          margin-right: 5px;
          padding-right: 2px;
        }
      }
      .itemZp {
        .el-form-item__content {
          margin-top: 8px;
        }
        div {
          line-height: 20px;
        }
      }
    }
    .el-table {
      .el-table__body-wrapper {
        height: 630px;
        overflow-x: inherit;
      }
    }
    .el-tabs__nav {
      margin-left: 30px;
    }
    .modalCheckBox {
      .el-checkbox-group {
        line-height: 18px;
        margin-left: 20px;
        margin-top: -5px;
        .el-checkbox {
          .el-checkbox__label {
            font-size: 12px;
            color: #666;
          }
        }
      }
      .el-checkbox {
        margin-right: 20px;
      }
      .el-checkbox + .el-checkbox {
        margin-left: 0;
      }
    }
  }
</style>

